/***************************************************************************
 *   Copyleft 2008-2009 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __VABSTRACTAPP_H__
#define __VABSTRACTAPP_H__

#include "../Framework/vEngine3D.h"
#include "../Framework/Config/vSetupConfig.h"
#include "../Window/ModalDialog/vSetupDialog.h"
#include "../Macros/vMemoryMacros.h"
#include "../Macros/vLogMacros.h"

namespace Vendetta {
	/*! \class vAbstractApp
	 *   \brief A vAbstractApp must be inherited to run the engine as single app. It is called in Main file.
	 *
	 */
	class vAbstractApp: public vFrameListener {
	public:
		/*! \brief Default constructor.
		 *
		 */	
		vAbstractApp();

		/*! \brief Default Destructor.
		 *
		 */	
		virtual ~vAbstractApp();

		/*! \brief Main routine where everything is done.
		 *
		 */	
		vVoid Run();

		/*! \brief Implemented from vFrameListener.
		 *
		 *	\sa	vFrameListener.
		 */
		virtual vVoid Update(const vFrameEvent& event) { }

		/*! \brief Implemented from vFrameListener.
		 *
		 *	\sa	vFrameListener.
		 */
		virtual vVoid BeginFrame(const vFrameEvent& event) { }

		/*! \brief Implemented from vFrameListener.
		 *
		 *	\sa	vFrameListener.
		 */	
		virtual vVoid EndFrame(const vFrameEvent& event) { }

	protected:
		/*! \brief Pure abstract method. It is used to create scene.
		 *
		 *	\return	True if everything goes right, false otherwise.
		 */
		virtual vBool createCamera() { return true;}

		/*! \brief Pure abstract method. It is used to create scene.
		 *
		 *	\return	True if everything goes right, false otherwise.
		 */
		virtual vBool createScene() { return true;}

		/*! \brief Pure abstract method. It is used to create scene.
		 *
		 *	\return	True if everything goes right, false otherwise.
		 */
		virtual vBool destroyScene() { return true;}

		/*! \brief Pure abstract method. It is used to create scene.
		 *
		 *	\param	list	Pointer to vFrameListener.
		 *	\sa		vFrameListener.
		 */
		vVoid addFrameListener(vFrameListener* list);

	protected:
		vSetupConfig mSetupConfig;		//! Config file loading at startup.
		vSetupDialog mSetupDialog;		//!	Setup dialog in case user don't want to choose save config.

	private:
		vBool setup();
	};
}

#endif // __VABSTRACTAPP_H__